import 'package:flutter/material.dart';

class AppInfoMenu extends StatelessWidget {
  const AppInfoMenu({super.key});

  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
        child: Column(
        children: [
          const _AppInfoMenuLine(),
          _AppInfoMenuItem(title: "功能介绍",onPressed: (){},),
          const _AppInfoMenuLine(),
          _AppInfoMenuItem(title: "检查更新",onPressed: (){},),
          const _AppInfoMenuLine(),
        ],
      ),
    );
  }
}

class _AppInfoMenuItem extends StatefulWidget {
  const _AppInfoMenuItem({super.key, required this.title, required this.onPressed});

  final String title;
  final Function onPressed;

  @override
  State<_AppInfoMenuItem> createState() => _AppInfoMenuItemState();
}

class _AppInfoMenuItemState extends State<_AppInfoMenuItem> with SingleTickerProviderStateMixin {
  late AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  void _onPressed(){
    widget.onPressed();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialButton(
      onPressed: _onPressed,
      child: Container(
        height: 60,
        padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text(widget.title,style: const TextStyle(fontSize: 18),),
            const Icon(Icons.chevron_right)
          ],
        ),
      ),
    );
  }
}

class _AppInfoMenuLine extends StatelessWidget {
  const _AppInfoMenuLine({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 1,
      child: Divider(
        height: 1.0,
        color: Colors.grey.shade300,
      ),
    );
  }
}


